home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: news.sprintlink.net!news1!news
- From: rclark@iquest.net (Robert B. Clark)
- Subject: Re: I can't print the date in the format I want.
- X-Nntp-Posting-Host: ind-008-237-94.iquest.net
- Message-ID: <312de5dc.416111@news.iquest.net>
- Sender: news@iquest.net (News Admin)
- Organization: IQuest Internet, Inc.
- X-Newsreader: Forte Agent .99d/16.182
- References: <4g5nbf$8s0@newsbf02.news.aol.com> <3129e355.114134@news.iquest.net> <825035732snz@genesis.demon.co.uk>
- Date: Fri, 23 Feb 1996 16:12:38 GMT
-
- On Fri, 23 Feb 96 00:35:32 GMT, Lawrence Kirby
- <fred@genesis.demon.co.uk> wrote:
-
- >In article <3129e355.114134@news.iquest.net>
- > rclark@iquest.net "Robert B. Clark" writes:
- >
- >>On second thought, I'll comment anyway. Your function ought to return
- >>some sort of value, if for no other reason than to reduce the flamewars
- >>people tend to get into over various permutations of the main()
- >>declaration:
- >>
- >> int main(void)
- >
- >Good advice but be aware that if the return type of a function
- >is unspecified it defaults to int. so ``main() {}'' defines a function that
- >takes no arguments and returns int.
-
- Thanks for the comments, Lawrence. I was aware of that, but I tend to
- prefer explicit-ness (new word) whenever feasible. :-)
-
- >>> debug = strftime(str, 50, "The current date is %y-%m-%d", ptr);
- >>
- >>"Possible use of 'str' before definition."
- >
- >Definite misuse of terminology :-)
-
- <chuckle> That's what my compiler (TC v3.0) reported.
-
- >>> getchar(); /* OK up to this point? */
- >>
- >>"Code has no effect."
- >>
- >>Doesn't do anything but wait for the user to press a key. If that was
- >>your intent, it would be better to express this as
- >>
- >> if getchar();
- >
- >Perhaps you meant:
- >
- > if (getchar());
-
- Yup. That's what I get for switching between Pascal and C in the same
- day without spending any time in the decontamination chamber. }:->
-
- >However all the if statement seems to do is obfuscate the code.
-
- Agreed. I figured it was there as a sort of pseudo-breakpoint, but I
- thought I'd comment on it anyway. I suggested that if the original
- poster wanted to use it thus, he might want to hide it in a moe
- appropriately-named macro, such as
-
- #define PAUSE if (getchar()) {}
-
- >The only portable values to return from main() are 0, EXIT_SUCCESS and
- >EXIT_FAILURE (the last 2 being defined in stdlib.h). return 0 or return
- >EXIT_SUCCESS is probably sensible here.
-
- Here is where my DOS/IBM-PC-centric side gets the better of me. I tend
- to write programs that return many "successful" exit codes, with only
- one particular value reserved to indicate an error. For that reason, I
- don't use the EXIT_* defines as often as some others might. Then again,
- most of my code is non-portable for other reasons as well. :-)
- --
- Robert B. Clark <rclark@iquest.net>
- "Be wary of strong spirits. It can make you shoot at tax collectors...
- and miss." --RAH
-